#include "BaseAbbre.h"

/*Get the max value or min value of any two values*/
UINT32 UnGetMaxValue(UINT32 FirstValue,UINT32 SecondValue)
{
    FirstValue > SecondValue ? return FirstValue : return SecondValue;
}

INT32 nGetMaxValue(INT32 FirstValue,INT32 SecondValue)
{
    FirstValue > SecondValue ? return FirstValue : return SecondValue;
}

UINT32 UnGetMinValue(UINT32 FirstValue,UINT32 SecondValue)
{
    FirstValue < SecondValue ? return FirstValue : return SecondValue;
}

INT32 nGetMinValue(INT32 FirstValue,INT32 SecondValue)
{
    FirstValue < SecondValue ? return FirstValue : return SecondValue;
}

/*Exchange two values in the case of Max_to_Min , Min_to_Max or just exchange*/
void ExJust(UINT32 *FirstValue, UINT32 *SecondValue)
{
    *FirstValue += *SecondValue;
    *SecondValue = *FirstValue - *SecondValue;
    *FirstValue  = *FirstValue - *SecondValue;    
}

void ExMax_to_Min(UINT32 *FirstValue, UINT32 *SecondValue)
{
    *FirstValue > *SecondValue ? return : ExJust(*FirstValue , *SecondValue); 
    return;
}

void ExMin_to_Max(UINT32 *FirstValue, UINT32 *SecondValue)
{
    *FirstValue < *SecondValue ? return : ExJust(*FirstValue , *SecondValue); 
    return;
}

/*Get the special order num of any number values*/
UINT32 UnGetMaxSpecialValue(UINT32 SpecialOrder, UINT32 *NumSeries)
{
    return GetMaxToMinSeries(SpecialOrder,NumSeries);
}

UINT32 UnGetMinSpecialValue(UINT32 SpecialOrder, UINT32 *NumSeries)
{
    return GetMinToMaxSeries(SpecialOrder,NumSeries);
}

/*Sort an array sequence*/
void OrderSeries(UINT32 TotalNumber, UINT32 *NumSeries, OrderType Type)
{
    UINT32 i = 0;
    UINT32 j = 0;
    for ( i = 0; i < TotalNumber - 1; i++ )
    {
        for ( j = i+1 ; j < TotalNumber; j++ )
        {
            if ( Max_to_Min == Type )
            {
                ExMax_to_Min( *( NumSeries + i ), *( NumSeries + j) );
            }
            else if ( Min_to_Max == Type)
            {
                ExMin_to_Max( *( NumSeries + i ), *( NumSeries + j) );
            }
            else
            {
                printf(" function err: %s",__FUNCTION__);
            }
        }
    }
    return;
}